
clear 

putexcel set "Results\tab_B1\table_5_lifetime_addon_eq", replace

putexcel B1 = "N (1,000s)"
putexcel B2 = "1990"
putexcel C2 = "2010"

putexcel D1 = "Sorting"
putexcel D2 = "1990"
putexcel E2 = "2010"
putexcel F2 = "Change"

putexcel G1 = "Gini, data"
putexcel G2 = "1990"
putexcel H2 = "2010"

putexcel I1 = "Gini (i)"
putexcel I2 = "2010"

putexcel J1 = "D Gini (i)/D Gini, data"


* Baseline for Life time earnings Sample

putexcel A3 = "Benchmark types"

clear
use "Results\tab_B1\Scenario_5\Sorting\results_ambition_19902010"

gen temp=male_1_marr+male_2_marr+male_3_marr+male_4_marr+female_1_marr+female_2_marr+female_3_marr+female_4_marr+male_1_sing+male_2_sing+male_3_sing+male_4_sing+female_1_sing+female_2_sing+female_3_sing+female_4_sing

qui sum temp if aar==1990
sca temp2=r(mean)/1000

putexcel B3 = temp2

qui sum temp if aar==2010
sca temp2=r(mean)/1000

putexcel C3 = temp2

drop temp

gen temp=s_1_1*(0*male_1+(1-0)*female_1)+s_2_2*(0*male_2+(1-0)*female_2)+s_3_3*(0*male_3+(1-0)*female_3)+s_4_4*(0*male_4+(1-0)*female_4)

qui sum temp if aar==1990
sca temp2=r(mean)

putexcel D3 = temp2

qui sum temp if aar==2010
sca temp3=r(mean)

putexcel E3 = temp3

sca temp4=(temp3-temp2)/temp2

putexcel F3 = temp4

drop temp

clear
use "Results\tab_B1\Scenario_5\Decomposition\results_ambition_19902010_eq"

qui sum gini if aar==1990
sca temp2=r(mean)

putexcel G3 = temp2

qui sum gini if aar==2010
sca temp3=r(mean)

putexcel H3 = temp3

qui sum gini_cf_sort if aar==2010
sca temp4=r(mean)

putexcel I3 = temp4

sca temp5=(temp4-temp2)/(temp3-temp2)

putexcel J3 = temp5

